package com.lanchetech.admin.controller;


import com.lanchetech.admin.service.ActivityService;
import com.lanchetech.bean.request.ActivityReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.ActivityVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/activity")
@Api(value = "新人专区活动", tags = "新人活动管理")
public class ActivityController {

    @Resource
    private ActivityService activityService;

    @ApiOperation("查看新人活动列表分页")
    @PostMapping("/getPage")
    public ResultData<BasePageResp<ActivityVo>> getPage(@RequestBody ActivityReq req){
        return activityService.getPage(req);
    }


    @ApiOperation("审核活动是否通过")
    @PostMapping("/audit")
    @PreAuthorize("hasAnyAuthority( 'marketing.newlywed-zone.list.examine.auth')")
    public BaseResp auditActivity(@RequestBody ActivityVo activityVo){
        return activityService.auditActivity(activityVo);
    }

    @ApiOperation("查看新人活动详情")
    @GetMapping("/getDetail")
    @PreAuthorize("hasAnyAuthority( 'marketing.newlywed-zone.list.info.auth')")
    public ResultData<ActivityVo> getDetail(@RequestParam("id") Long id){
        return activityService.getDetail(id);
    }
}
